package net.homeip.jcperera.nu.security.credential;

import java.io.Serializable;

import javax.inject.Named;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

/**
 * Credential, for authentication, to present in behalf of a SecurityPrincipal
 * 
 * @name Credential class
 * @author julio.c.perera@gmail.com
 * @application nu
 * @since 0.1.0.0
 */

@Named(Credential.componentName)
@MappedSuperclass
public class Credential implements Serializable
{
    // Required to implement Serializable interface
    private static final long  serialVersionUID = 8389922915009464754L;

    // CoreBase properties, for easy use from other components, as well as logging
    public static final int    runtimeLevel     = 2;
    public static final String moduleName       = "security";
    public static final String componentName    = "nu_security_credential";

    @Basic
    @Column(name = "CREDENTIAL")
    private String             value            = "";

    /**
     * Verifies that the Credential is valid against the reference passed as parameter
     * 
     * @param valueToVerify
     *            the reference value to check against
     */
    public boolean verify(Credential valueToVerify)
    {
        return true;
    }

    /**
     * Gets the current value of the current credential, for persistence related functionality (mostly), you should not
     * use this value to make comparisons, but use the method {@link #verify()} instead
     */
    public String getValue()
    {
        return this.value;
    }

    /**
     * Sets the value to the <code>String</code> passed as parameter
     * 
     * @param newValue
     *            the value to set
     */
    public void setValue(String newValue)
    {
        this.value = newValue;
    }

    @Override
    public String toString()
    {
        return this.value;
    }
}